package es.unex.meigas.core;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

public class SpeciesCatalog {

	private String[] m_Species = new String[0];

	public String[] getSpecies(){

		return m_Species;

	}

	public void open(String file) {

		ArrayList<String> species = new ArrayList<String>();

		try {

			BufferedReader input =  new BufferedReader(new FileReader(file));
			try {
				String line = null; //not declared within while loop
				while (( line = input.readLine()) != null){
					species.add(line);
				}
			}
			finally {
				input.close();
			}
		}
		catch (IOException ex){
			ex.printStackTrace();
		}

		m_Species = (String[]) species.toArray(new String[0]);
		Arrays.sort(m_Species);

	}

}
